package com.soft.link.controller.tsystem;

import com.alibaba.fastjson.JSONObject;
import com.soft.link.controller.BaseController;
import com.soft.link.model.TreeView;
import com.soft.link.service.TsRoleMenuService;
import com.soft.link.utils.MsgEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * company 重庆庆云石油工程技术有限责任公司
 * FileName TsRoleMenuController
 * Package com.soft.link.controller.tsystem
 * Description 菜单角色按钮
 * author Administrator
 * create 2018-04-27 11:19
 * version V1.0
 */
@Controller
@RequestMapping("system/tsRoleMenu")
public class TsRoleMenuController extends BaseController {
    @Autowired
    TsRoleMenuService tsRoleMenuService ;

    /**
     * @param roleId       角色Id
     * @param treeViewList 选中的角色的树
     * @throws {ajaxAddTsRoleMenu:选中的角色树}
     * @methodname ajaxAddTsRoleMenu
     * @Description 角色权限赋值
     * @author 黄学乾
     * @create 2018/4/28/028 16:31
     */
    @RequestMapping("ajaxAddTsRoleMenu")
    @ResponseBody
    public JSONObject ajaxAddTsRoleMenu(String roleId, String treeViewList) {
        JSONObject jsonObject = new JSONObject();
        try {
            tsRoleMenuService.insertTsRoleMenu(roleId, JSONObject.parseArray(treeViewList, TreeView.class), getTsUser());
            jsonObject.put("state", true);
            jsonObject.put("msg",MsgEnum.Add_Success.getDesc());
        } catch (Exception e) {
            jsonObject.put("state", false);
            jsonObject.put("msg",MsgEnum.Add_False.getDesc());
            e.printStackTrace();
        }
        return jsonObject;
    }


}
